package com.bw.permission.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Getter
public enum SexEnum {
    nan(1,"男"),nv(2,"女");

//    @JsonValue
    @EnumValue //数据库存的值
    private Integer value;
    @JsonValue
    private String name;

    SexEnum(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public static List<HashMap<String,Object>> getSexList(){
        List<HashMap<String,Object>> sexList  = new ArrayList<>();
        SexEnum[] values = SexEnum.values();
        for (int i = 0; i < values.length; i++) {
            SexEnum sexEnum = values[i];
            HashMap<String,Object> sexMap = new HashMap<>();
            sexMap.put("id",sexEnum.ordinal());
//            sexMap.put("id",sexEnum.getValue());
            sexMap.put("name",sexEnum.getName());
            sexList.add(sexMap);
        }
        return sexList;
    }

}
